home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_glimpse.idb / usr / freeware / src / glimpse-3.0 / agrep / agrep.h.z / agrep.h
C/C++ Source or Header  |  1997-09-09  |  5KB  |  143 lines

  1. /* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal.  All Rights Reserved. */
  2. #ifndef _AGREP_H_
  3. #define _AGREP_H_
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <math.h>
  7. #include <ctype.h>
  8. #include "re.h"
  9. #include "defs.h"
  10. #include "config.h"
  11. #include <fcntl.h>
  12. #include <unistd.h>
  13. #include <string.h>
  14.  
  15. #define MAXNUM_PAT  16    /* 32 parts of a pattern = width of expression-tree */
  16. #define CHAR    unsigned char
  17. #define MAXPAT 256
  18. #define MAXPATT 256
  19. #define MAXDELIM 8    /* Max size of a delimiter pattern */
  20. #define SHORTREG 15
  21. #define MAXREG   30
  22. #define MAXNAME  256
  23. #define Max_Pats 12    /* max num of patterns */
  24. #define Max_Keys 12     /* max num of keywords */
  25. #define Max_Psize 128   /* max size of a pattern counting all the characters */
  26. #define Max_Keyword 31  /* the max size of a keyword */
  27. #define WORD 32         /* the size of a word */
  28. #define MaxError 8      /* the max number of errors allowed */
  29. #define MaxRerror 4     /* the max number of erros for regular expression */
  30. #define MaxDelimit 16   /* the max raw length of a user defined delimiter */
  31. #define BlockSize  49152
  32. #define Max_record 49152
  33. #define SIZE 16384       /* BlockSIze in sgrep */
  34. #define MAXLINE   1024  /* maxline in sgrep */
  35. #define MAX_LINE_LEN 1024
  36. #define Maxline   1024
  37. #define RBLOCK    8192
  38. #define RMAXLINE  1024
  39. #define MaxNext   66000
  40. #define ON 1
  41. #define OFF 0
  42. #define Compl 1
  43. #define Maxresult 10000
  44. #define MaxCan 2500
  45.  
  46. #if    1
  47. #define MAXSYM 256 /* ASCII */
  48. #define WORDB     133    /* -w option */
  49. #define LPARENT   134    /* ( */
  50. #define RPARENT   135    /* ) */
  51. #define LRANGE    136    /* [ */
  52. #define RRANGE    137    /* ] */
  53. #define LANGLE    138    /* < */
  54. #define RANGLE    139    /* > */
  55. #define NOTSYM    140    /* ^ */
  56. #define WILDCD    141    /* wildcard */
  57. #define ORSYM     142   /* | */
  58. #define ORPAT     143   /* , */
  59. #define ANDPAT    144   /* ; */
  60. #define STAR      145   /* closure */
  61. #define HYPHEN    129   /* - */
  62. #define NOCARE    130   /* . */
  63. #define NNLINE    131   /* special symbol for newline in begin of pattern*/
  64.                        /* matches '\n' and NNLINE */
  65. #define USERRANGE_MIN 128     /* min char in pattern of user: give warning */
  66. #define USERRANGE_MAX 145    /* max char in pattern of user: give warning */
  67. #else
  68. #define MAXSYM 256 /* ASCII */
  69. #define WORDB     241    /* -w option */
  70. #define LPARENT   242    /* ( */
  71. #define RPARENT   243    /* ) */
  72. #define LRANGE    244    /* [ */
  73. #define RRANGE    245    /* ] */
  74. #define LANGLE    246    /* < */
  75. #define RANGLE    247    /* > */
  76. #define NOTSYM    248    /* ^ */
  77. #define WILDCD    249    /* wildcard */
  78. #define ORSYM     250   /* | */
  79. #define ORPAT     251   /* , */
  80. #define ANDPAT    252   /* ; */
  81. #define STAR      253   /* closure */
  82. #define HYPHEN    237   /* - */
  83. #define NOCARE    238   /* . */
  84. #define NNLINE    239   /* special symbol for newline in begin of pattern*/
  85.                        /* matches '\n' and NNLINE */
  86. #define USERRANGE_MIN 236     /* min char in pattern of user: give warning */
  87. #define USERRANGE_MAX 255    /* max char in pattern of user: give warning */
  88. #endif
  89.  
  90. #define OUTPUT_OVERFLOW    /* fprintf(stderr, "Output buffer overflow after %d bytes @ %s:%d !!\n", agrep_outpointer, __FILE__, __LINE__) */
  91. extern unsigned char *forward_delimiter(), *backward_delimiter();
  92. extern int exists_delimiter();
  93. extern void preprocess_delimiter();
  94. unsigned char *forward_delimiter(), *backward_delimiter();
  95. int exists_tcompressed_word();
  96. unsigned char * forward_tcompressed_word(), *backward_tcompressed_word();
  97. void alloc_buf(), free_buf();
  98.  
  99. #define AGREP_VERSION    "3.0"
  100. #define AGREP_DATE    "1994"
  101.  
  102.  
  103. /* To parse patterns in asplit.c */
  104. #define AND_EXP 0x1    /* boolean ; -- remains set throughout */
  105. #define OR_EXP 0x2    /* boolean , -- remains set throughout */
  106. #define ATTR_EXP 0x4    /* set when = is next non-alpha char, remains set until next , or ; --> never used in agrep */
  107. #define VAL_EXP 0x8    /* set all the time except when = is seen for first time --> never used in agrep */
  108. #define ENDSUB_EXP 0x10    /* set when , or ; is seen: must unset ATTR_EXP now --> never used in agrep */
  109.  
  110. #define INTERNAL 1
  111. #define LEAF 2
  112. #define NOTPAT 0x1000
  113. #define OPMASK 0x00ff
  114.  
  115. typedef struct _ParseTree {
  116.         short   op;
  117.         char    type;
  118.         char    terminalindex;
  119.         union {
  120.                 struct {
  121.                         struct _ParseTree *left, *right;
  122.                 } internal;
  123.                 struct {
  124.                         unsigned char    *attribute;    /* never used in agrep */
  125.                         unsigned char    *value;
  126.                 } leaf;
  127.         } data;
  128. } ParseTree;
  129.  
  130. #define unget_token_bool(bufptr, tokenlen) (*(bufptr)) -= (tokenlen)
  131.  
  132. #define dd(a,b)    1
  133. #define AGREP_ERROR    123    /* errno = 123 means that glimpse should quit searching files: used for errors glimpse itself cannot detect but agrep can */
  134.  
  135. #if    ISO_CHAR_SET    /* From Henrik.Martin@eua.ericsson.se (Henrik Martin) */
  136. #define IS_LOCALE_CHAR(c) ((isalnum((c)) || isxdigit((c)) || \
  137.     isspace((c)) || ispunct((c)) || iscntrl((c))) ? 1 : 0)
  138. #define ISASCII(c)    IS_LOCALE_CHAR(c)
  139. #else
  140. #define ISASCII(c)    isascii(c)
  141. #endif
  142. #endif /* _AGREP_H_ */
  143.